package cxm.test.speex;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import cxm.lib.speex.EchoCancellation;
import cxm.lib.speex.Preprocessor;
import cxm.lib.speex.SpeexException;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        int frameSize = 160;
        short []testBuffer = new short[frameSize];
        try {
        	Preprocessor pro = new Preprocessor(frameSize, 8000);
        	EchoCancellation aec = new EchoCancellation(frameSize, 160 * 10);
        	pro.enableEchoCancel(aec);
        	
        	// preprocessor buffer
        	pro.run(testBuffer);
        	aec.playback(testBuffer);
        	short []outBuffer = new short[frameSize];
        	aec.capture(testBuffer, outBuffer);
        } catch (SpeexException e) {
        	Log.e("MainActivity", "Cannot create speex: " + e);
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
